<template>
  <div id="app">
    <el-cascader
      size="large"
      :options="pcaTextArr"
      @change="sendInfo"
      v-model="selectedOptions">
    </el-cascader>
  </div>
</template>

<script>
import {pcaTextArr, regionData} from 'element-china-area-data'
  export default {
  props:['local'],
    data () {
      return {
        pcaTextArr,
        selectedOptions: []
      }
    },
    watch: {
      local(newValue) {
        if (newValue !== ''){
          this.selectedOptions = newValue
        }else {
          this.selectedOptions = []
        }
      },
    },
    mounted() {
      this.getLocalInfo()
    },
    methods: {
      getLocalInfo(){
        if (this.local){
          this.selectedOptions = this.local
        }else {
          this.selectedOptions = []
        }
      },
      pcaTextArr() {
        return pcaTextArr
      },
      sendInfo(){
        this.$emit('formLocalInfo',this.selectedOptions)
      },
    },
  }
</script>

<style scoped>

</style>
